#include "IncrementalRotation.h"
#include "TexturedEntity.h"

IncrementalRotation::IncrementalRotation(TexturedEntity* entity, const float step, 
                                         const float stepDelay, const Vector3& rotationAxes)
: Animation(entity), m_step(step), m_timer(0.0f), m_stepDelay(stepDelay), m_rotationAxes(rotationAxes)
{
    m_loop = true;
}

IncrementalRotation::~IncrementalRotation(void)
{
}

void IncrementalRotation::onUpdate(float dT)
{
    m_timer += dT;
    if ((m_timer * 1000.0f) >= m_stepDelay)
    {
        Vector3 newAngle = m_entity->getRotationAngles() * m_rotationAxes;
        newAngle += (m_rotationAxes * m_step);
        m_entity->setRotationAngles(newAngle);
        m_timer = 0.0f;
    }
}
